<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>ref-基础用法</title>
</head>

<body>


  <script src="https://unpkg.com/vue@3/dist/vue.global.js"></script>
  <div id="Application">
    <div>
      <div>countRef:{{countRef}}</div>
      <div>objCountRef:{{objCountRef.count}}</div>
      <div>爱好：{{hobbyRef.join('---')}}</div>
      <mark>join把数组中的所有元素转换为一个字符串：</mark>
    </div>
  </div>
  <script>
    const App = Vue.createApp({
      setup() {
        // 值类型
        const countRef = Vue.ref(1);
        console.log(countRef);

        // 对象
        const objCountRef = Vue.ref({ count: 1 });

        // 数组
        const hobbyRef = Vue.ref(["爬山", "游泳"]);

        setTimeout(() => {
          // 通过value改变值
          countRef.value = 2;
          objCountRef.value.count = 3;
          hobbyRef.value.push("吃饭");
        }, 4000);

        return {
          countRef,
          objCountRef,
          hobbyRef,
        };
      },
    });
    App.mount("#Application");
  </script>
</body>

</html>